import os

# Extract the translatable text from the html templates
# see http://genshi.edgewall.org/wiki/GenshiTutorial/Internationalization

# The equivalent command line
#pybabel extract -o locale/slidespeech.pot -F ./mapping.cfg .

env = Environment(ENV = os.environ)
templates = Glob('templates/*.html')
env.Command('locale/slidespeech.pot',
            templates,
            "pybabel extract -F ./mapping.cfg -o $TARGET .")

# For each locale generate the initial .po file manually - caution this will overwrite
# an existing file.
#>pybabel init -D slidespeech -i locale/slidespeech.pot -d locale/ -l en
#>pybabel init -D slidespeech -i locale/slidespeech.pot -d locale/ -l de

# Use the PyBabel update command for merging translated .po files

# Create .mo from .po files
pofiles = Glob('locale/*/LC_MESSAGES/slidespeech.po')
mofiles = Glob('locale/*/LC_MESSAGES/slidespeech.mo')

# The pybabel compile command operates on the whole locale dir, so if
# one source file changes then they will all get rebuilt.
# FIXME: this doesn't work on Linux
env.Command(mofiles,
            pofiles,
            "pybabel compile -D slidespeech -d locale/ -f --statistics")

